<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 01:16:57
 * @LastEditTime: 2023-10-19 12:23:43
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 盘点单
 */

namespace App\Models;

use App\Traits\AttachmentTrait;
use App\Traits\StorageTrait;
use App\Traits\AutoCodeTrait;
use App\Traits\CarryTrait;
use App\Traits\CarTrait;
use App\Traits\SoftDeletesTrait;

class MpcDeptAllocation extends BaseModel
    {
    use SoftDeletesTrait;
    use AutoCodeTrait;
    use AttachmentTrait;

    public $timestamps = true;
    public $table = "sys_mpc_deptallocation";
    public $attachmentkey = "code";
    protected $guarded = [];

    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'ALLOCATION';

    /**
     * 编号所用的字段
     *
     * @var string
     */
    protected $ACCode = 'code';
    public function details()
        {
        return $this->hasMany(MpcDeptAllocationDetail::class, "main_id");
        }
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'status_name');
            });
        }
    /**
     * Summary of carry
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author sunkaiyuan
     */
    public function carry()
        {
        return $this->belongsTo(ComprehensiveCarry::class);
        }
    /**
     * Summary of car
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author sunkaiyuan
     */
    public function car()
        {
        return $this->belongsTo(ComprehensiveCar::class);
        }
    }